package com.cq.hd.member.controller;

import com.cq.hd.common.response.Result;
import com.cq.hd.common.response.ResultGenerator;
import com.cq.hd.member.api.TbUserBusinessApi;
import com.cq.hd.member.service.TbUserBusinessService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 用户-商家关联表 前端控制器
 * </p>
 */
@RestController
public class TbUserBusinessController implements TbUserBusinessApi {

    @Autowired
    private TbUserBusinessService userBusinessService;

    @ApiOperation(value = "根据用户id获取商家id列表")
    @ApiImplicitParam(name = "userId", value = "实体", paramType = "query", dataType = "Long")
    @Override
    public Result<List<Long>> getBusinessIdsByUserId(Long userId) {
        return ResultGenerator.success(userBusinessService.getBusinessIdsByUserId(userId));
    }

    @ApiOperation(value = "用户跟商家关联")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "实体", paramType = "query", dataType = "Long"),
            @ApiImplicitParam(name = "businessId", value = "实体", paramType = "query", dataType = "Long")
    })
    @Override
    public Result<Boolean> related(Long userId, Long businessId) {
        return ResultGenerator.success(userBusinessService.related(userId, businessId));
    }
}
